<div class="page-3 cart commonPage">
	<div class="bg-3"></div>
	<?php echo $this->element('sidebar'); ?>
	<div class="box-right zhigh">
        <?php echo $this->element('banner'); ?>
			<div class="title">
                <ul class="breadcrumbs">
                    <li><a href="<?php echo $this->General->base_url() ?>"><img style="position: relative; top: 2px;" src="<?php echo $this->webroot ?>images/home-yl-2.png" /></a></li>
                    <?php
                        foreach($breadcrumbs as $breadcrumb)
                        {
                            echo '<li><a href="'.$this->General->base_url().$breadcrumb['link'].'">'.$breadcrumb['title'].'</a></li>';
                        }
                    ?>
                </ul>
			</div>
		<?php echo $this->element('header'); ?>
		<div class="box-content">
			<div class="post-content">
                <?php
                    
                        
                    if($this->session->check('Message.flash'))
                    {
                ?>
				<div class="cart-title">
					<div class="img">
						<img src="images/cart-i.png"/>
					</div>
					<div class="txt">
						<span class="added"><?php echo $this->Session->flash(); ?></span>
						<span>Bạn có <?php echo count($carts) ?> <?php $this->General->translate('product_in_cart') ?></span>
					</div>
				</div>
                <?php
                    }
                ?>
                <?php
                    if(count($carts) > 0)
                    {
                ?>
				<div class="cart-out">
					<div class="col-price">
						<strong><?php $this->General->translate('price') ?></strong>
					</div>
					<div class="col-mount">
						<strong><?php $this->General->translate('total_number') ?></strong>
					</div>
					<div class="col-total">
						<strong><?php $this->General->translate('sum_price') ?></strong>
					</div>
				</div>
                <?php
                    }
                ?>
				<div class="cart-content">
                <?php
                    $sum_amount = 0;
                    foreach($carts as $product_id => $cart)
                    {
                ?>
					<div class="item">
						<div class="box-img">
							<a href="#"><img src="<?php echo $this->webroot . $cart['image'] ?>"/></a>
						</div>
						<div class="col-pro">
							<h3><?php echo $cart['title'] ?></h3>
							<div class="check">
                                <?php
                                    if(@$cart['in_stock'] == 1)
                                        echo '<span class="pro">'.$this->General->get_translate('in_stock').'</span>';
                                    else
                                        echo '<span class="pro not_stock">'.$this->General->get_translate('out_stock').'</span>';
                                ?>
								
                                 | 
								<a order="delete" product_id="<?php echo $product_id ?>" href="javascript:void(0)" class="delete"><?php $this->General->translate('delete') ?></a>
							</div>
						</div>
						<div class="col-price">
                            <?php
                                if($cart['discount']!='' && $cart['discount']!=0)
                                {
                            ?>
        							<span class="sell"><?php echo ($cart['discount']!='' && $cart['discount']!=0) ? number_format($cart['discount'],0,',','.') .' '. $settings['currency'] : '' ?></span><br/>
        							<span class="real"><?php echo ($cart['price']!='' && $cart['price']!=0) ? number_format($cart['price'],0,',','.') .' '. $settings['currency'] : '' ?></span><br/>
        							<span class="off"><?php echo ($cart['percent_discount']!='' && $cart['percent_discount']!=0) ? $this->General->get_translate('down').' '.$cart['percent_discount'].'%' : '' ?></span>
						     <?php
                                }
                                else
                                {
                            ?>
                                    <span class="sell"><?php echo ($cart['price']!='' && $cart['price']!=0) ? number_format($cart['price'],0,',','.') .' '. $settings['currency'] : '' ?></span><br/>
                            <?php
                                }
                             ?>
                        </div>
						<div class="col-mount">
							<select order="change" product_id="<?php echo $product_id ?>" name="">
                                <?php
                                    for($i = 1; $i <= 50; $i++)
                                    {
                                        $selected = $i == $cart['number'] ? "selected='selected'" : "";
                                ?>
								<option <?php echo $selected ?> value="<?php echo $i ?>"><?php echo $i ?></option>
                                <?php
                                    }
                                ?>
							</select>
						</div>
						<div class="col-total">
                            <?php
                                $gia = $cart['discount'] > 0 ? $cart['discount'] : $cart['price'];
                                $amount = $gia * $cart['number'];
                                $sum_amount += $amount;
                            ?>
							 <?php echo ($amount!=0) ? number_format($amount,0,',','.') .' '. $settings['currency'] : '' ?>
						</div>
					</div>
                <?php
                    }
                    if(count($carts) == 0)
                        echo '<p class="not_order">'.$this->General->translate('not_product_in_cart').'</p>';
                ?>
					<div class="clear"></div>
				</div>
                
				<div class="check-out">
                <?php
                    if(count($carts) > 0)
                    {
                ?>
					<div class="total">
						<span><?php $this->General->translate('sum_price') ?></span>
						<span><?php echo ($sum_amount!=0) ? number_format($sum_amount,0,',','.') .' '. $settings['currency'] : '' ?></span>
					</div>
					<div class="money">
						<span><?php $this->General->translate('thanh_tien') ?></span>
						<span><?php echo ($sum_amount!=0) ? number_format($sum_amount,0,',','.') .' '. $settings['currency'] : '' ?></span>
					</div>
                <?php
                    }
                ?>
				</div>
                
				<div class="link_to">
					<a href="<?php echo $this->Html->url(array('controller' => 'products', 'action' => 'index')) ?>" class="addmore"><?php $this->General->translate('add_product_into_cart') ?></a>
					<?php
                        if(count($carts) > 0)
                        {
                    ?>
                    <a href="<?php echo $this->Html->url(array('controller' => 'checkout', 'action' => 'index')) ?>" class="putorder"><?php $this->General->translate('continute_checkout') ?> >></a>
                    <?php
                        }
                    ?>
				</div>
			</div>
		</div>
	</div>
	<?php echo $this->element('footer'); ?>
</div>
